<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib prefix="xdz" uri="/xdztools" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>管理后台首页</title>

<link href="${xdz:domain() }/css/bootstrap.min.css" rel="stylesheet">
<link href="${xdz:domain() }/css/font-awesome.min.css" rel="stylesheet">
<link href="${xdz:domain() }/css/animate.min.css" rel="stylesheet">
<link href="${xdz:domain() }/css/style.min.css" rel="stylesheet">
</head>

<body class="fixed-sidebar full-height-layout gray-bg" style="overflow:scroll;" >
    <div id="wrapper">
        <!--左侧导航开始-->
        <nav class="navbar-default navbar-static-side" role="navigation">
            <div class="nav-close"><i class="fa fa-times-circle"></i>
            </div>
            <div class="sidebar-collapse">
                <ul class="nav" id="side-menu">
                    <li class="nav-header">
                        <div class="dropdown profile-element" style="text-align: center">
                            <span><img id="tx" alt="image" style="width:50px" class="img-circle" src="${currentUser.img }" /></span>
                            <a data-toggle="dropdown" class="dropdown-toggle" href="#">
                                <span class="clear">
<!--                                 <span class="block m-t-xs"> -->
<!-- 	                               	<strong class="font-bold">Beaut-zihan</strong> -->
<!-- 	                            </span> -->
		                            <span class="text-muted text-xs block">
		                            	${currentUser.userName }<b class="caret"></b>
		                            </span>
                                </span>
                            </a>
                            <ul class="dropdown-menu animated fadeInRight m-t-xs">
                            	<li><a id="uploadImg" href="javascript:void(0)">修改头像</a>
                            	<li class="divider"></li>
                            	<li><a href="../systemUserBase/updatePassword" class="J_menuItem" data-index="0">修改密码</a>
                                <li class="divider"></li>
                                <li><a href="${xdz:domain() }/loginout">安全退出</a>
                                </li>
                            </ul>
                        </div>
                        <div class="logo-element">HTZOS</div>
                    </li>
                    <c:if test="${!empty menuTrees }">
                    	<c:forEach items="${menuTrees }" var="menuTree" varStatus="vs">
                    		<c:if test="${fn:length(menuTree.value) == 1 }">
	                    		 <li>
			                        <a class="J_menuItem" href="${menuTree.value[0].menuUrl }" data-index="a${vs.count }"><i class="${menuTree.value[0].menuIcon }"></i> <span class="nav-label">${menuTree.value[0].menuName }</span></a>
			                    </li>
                    		</c:if>
                    		<c:if test="${fn:length(menuTree.value) > 1 }">
	                    		 <li>
			                        <a href="#">
			                            <i class="${menuTree.icon }"></i>
			                            <span class="nav-label">${menuTree.name }</span>
			                            <span class="fa arrow"></span>
			                        </a>
			                         <ul class="nav nav-second-level">
				                    	<c:forEach items="${menuTree.value }" var="roleMenu" varStatus="rvs">
				                    		 <li>
				                                <a class="J_menuItem" href="${roleMenu.menuUrl }" attr="${roleMenu.menuName }" data-index="b${rvs.count }"> <i class="${roleMenu.menuIcon }"></i> ${roleMenu.menuName }</a>
				                            </li>
				                    	</c:forEach>
			                    	 </ul>
			                    </li>
                    		</c:if>
                    	</c:forEach>
                    </c:if>
                </ul>
            </div>
        </nav>
        <!--左侧导航结束-->
        <!--右侧部分开始-->
        <div id="page-wrapper" class="gray-bg dashbard-1">
            <div class="row border-bottom">
                <nav class="navbar navbar-static-top" role="navigation" style="margin-bottom: 0">
                    <div class="navbar-header">
                    	<span class="navbar-minimalize minimalize-styl-2 "><a href="#"><i class="fa fa-bars"></i> HZTOS-LOGO</a></span>
                    </div>
                    <ul class="nav navbar-top-links navbar-right">
<!--                         <li class="dropdown"> -->
<!--                             <a class="dropdown-toggle count-info" id="message" data-toggle="dropdown" href="#"> -->
<!--                                 <i class="fa fa-bell" ></i>  -->
<!--                                 <span class="label label-warning" id="messnum"></span> -->
<!--                             </a> -->
<!--                             <ul class="dropdown-menu dropdown-messages"> -->
<!--                                 <li class="m-t-xs"> -->
<!--                                     <div class="dropdown-messages-box"> -->
<!--                                         <a href="profile.html" class="pull-left"> -->
<!--                                             <img alt="image" class="img-circle" src="img/a7.jpg"> -->
<!--                                         </a> -->
<!--                                         <div class="media-body"> -->
<!--                                             <small class="pull-right">46小时前</small> -->
<!--                                             <strong>小四</strong> 这个在日本投降书上签字的军官，建国后一定是个不小的干部吧？ -->
<!--                                             <br> -->
<!--                                             <small class="text-muted">3天前 2014.11.8</small> -->
<!--                                         </div> -->
<!--                                     </div> -->
<!--                                 </li> -->
<!--                                 <li class="divider"></li> -->
<!--                                 <li> -->
<!--                                     <div class="dropdown-messages-box"> -->
<!--                                         <a href="profile.html" class="pull-left"> -->
<!--                                             <img alt="image" class="img-circle" src="img/a4.jpg"> -->
<!--                                         </a> -->
<!--                                         <div class="media-body "> -->
<!--                                             <small class="pull-right text-navy">25小时前</small> -->
<!--                                             <strong>国民岳父</strong> 如何看待“男子不满自己爱犬被称为狗，刺伤路人”？——这人比犬还凶 -->
<!--                                             <br> -->
<!--                                             <small class="text-muted">昨天</small> -->
<!--                                         </div> -->
<!--                                     </div> -->
<!--                                 </li> -->
<!--                                 <li class="divider"></li> -->
<!--                                 <li> -->
<!--                                     <div class="text-center link-block"> -->
<%--                                         <a class="J_menuItem" href="${xdz:domain() }/disreadList" data-index="1"> --%>
<!--                                             <i class="fa fa-envelope"></i> <strong> 查看所有消息</strong> -->
<!--                                         </a> -->
<!--                                     </div> -->
<!--                                 </li> -->
<!--                             </ul> -->
<!--                         </li> -->
<!--                         <li class="dropdown"> -->
<%--                             <a class="dropdown-toggle count-info" data-toggle="dropdown" id="notic" href="${xdz:domain() }/acFeedbackBase/addPage"> --%>
<!--                                 <i class="fa fa-envelope"></i>  -->
<!--                                 <span class="label label-primary"></span> -->
<!--                             </a> -->
<!--                             <ul class="dropdown-menu dropdown-alerts"> -->
<!--                                 <li> -->
<!--                                     <a href="mailbox.html"> -->
<!--                                         <div> -->
<!--                                             <i class="fa fa-envelope fa-fw"></i> 您有16条未读消息 -->
<!--                                             <span class="pull-right text-muted small">4分钟前</span> -->
<!--                                         </div> -->
<!--                                     </a> -->
<!--                                 </li> -->
<!--                                 <li class="divider"></li> -->
<!--                                 <li> -->
<!--                                     <a href="profile.html"> -->
<!--                                         <div> -->
<!--                                             <i class="fa fa-qq fa-fw"></i> 3条新回复 -->
<!--                                             <span class="pull-right text-muted small">12分钟钱</span> -->
<!--                                         </div> -->
<!--                                     </a> -->
<!--                                 </li> -->
<!--                                 <li class="divider"></li> -->
<!--                                 <li> -->
<!--                                     <div class="text-center link-block"> -->
<!--                                         <a class="J_menuItem" href="notifications.html"> -->
<!--                                             <strong>查看所有 </strong> -->
<!--                                             <i class="fa fa-angle-right"></i> -->
<!--                                         </a> -->
<!--                                     </div> -->
<!--                                 </li> -->
<!--                             </ul> -->
<!--                         </li> -->

						 <li class="hidden-xs">
                            <a href="../disreadList" class="J_menuItem" data-index="xx"><i class="fa fa-bell"></i>系统消息</a>
                        </li>
					  	<li class="dropdown hidden-xs">
                            <a class="right-sidebar-toggle" aria-expanded="false" data-index="xx"><i class="fa fa-bullhorn"></i>通知公告</a>
                        </li>
                        <li class="hidden-xs">
                            <a href="../acFeedbackBase/listmine" class="J_menuItem" data-index="ly"><i class="fa fa-envelope"></i>留言站长</a>
                        </li>
                        <li class="hidden-xs">
                            <a href="../systemUserBase/updatePassword" class="J_menuItem" data-index="0"><i class="fa fa-key"></i>修改密码</a>
                        </li>
                        <li class="hidden-xs">
                        	<a href="${xdz:domain() }/loginout" ><i class="fa fa fa-sign-out"></i> 退出</a>
                    	</li>
                    </ul>
                </nav>
            </div>
            <div class="row content-tabs">
                <button class="roll-nav roll-left J_tabLeft"><i class="fa fa-backward"></i>
                </button>
                <nav class="page-tabs J_menuTabs">
                    <div class="page-tabs-content">
                        <a href="javascript:;" class="active J_menuTab" data-id="index">首页</a>
                    </div>
                </nav>
                <button class="roll-nav roll-right J_tabRight"><i class="fa fa-forward"></i>
                </button>
                <div class="btn-group roll-nav roll-right">
                    <button class="dropdown J_tabClose" data-toggle="dropdown">关闭操作<span class="caret"></span>

                    </button>
                    <ul role="menu" class="dropdown-menu dropdown-menu-right">
                        <li class="J_tabCloseAll"><a>关闭全部选项卡</a>
                        </li>
                        <li class="J_tabCloseOther"><a>关闭其他选项卡</a>
                        </li>
                    </ul>
                </div>
            </div>
            <div class="row J_mainContent" id="content-main">
                <iframe class="J_iframe" name="iframe0" width="100%" height="100%" src="${xdz:domain() }/welcome" frameborder="0" data-id="index" seamless></iframe>
            </div>
            <div class="footer">
                <div class="pull-right">
                	Created by 徐德志 - Copyright 2016
                </div>
            </div>
        </div>
        
        <!--右侧边栏开始-->
        <div id="right-sidebar">
            <div class="sidebar-container">

                <ul class="nav nav-tabs navs-1">
                    <li class="active" style="width:100%;">
                        <a data-toggle="tab" style="background:black;color:#fff;" href="#tab-3">
                            <i class="fa fa-bullhorn"></i> 最新公告
                        </a>
                    </li>
                </ul>

                <div class="tab-content">
                    <div id="tab-3" class="tab-pane active">
                        <ul class="sidebar-list notices">

                        </ul>
                    </div>
                </div>

            </div>
        </div>
        <!--右侧部分结束-->
   
    </div>
    <script src="${xdz:domain() }/js/jquery.min.js"></script>
    <script src="${xdz:domain() }/js/bootstrap.min.js"></script>
    <script src="${xdz:domain() }/js/plugins/metisMenu/jquery.metisMenu.js"></script>
    <script src="${xdz:domain() }/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
    <script src="${xdz:domain() }/js/plugins/layer/layer.min.js"></script>
    <script src="${xdz:domain() }/js/hplus.min.js"></script>
    <script src="${xdz:domain() }/js/contabs.min.js"></script>
    <script src="${xdz:domain() }/js/plugins/pace/pace.min.js"></script>
    
    <script>
    
    window.onload = function() {
	    init();  //初始化
	}

	//初始化
	function init() {
		var btnImg= document.getElementById("uploadImg"); 
	    //初始化图片上传
	    var img = document.getElementById("tx");
	    ajaxUploadImg(btnImg, img);
	}

    
    function ajaxUploadImg(button,img) {
	    new AjaxUpload(button, {
	    	action : '../upload/fileupload',
			data : {
				'timestamp' : (new Date()).getTime(),
				'token' : '',
				'key3' : "文件将被覆盖"
			},
			accept : 'image/*',
	        multiple : true,
	        onSubmit: function(file, ext) {
	            if (!(ext && /^(jpg|JPG|png|PNG|gif|GIF)$/.test(ext))) {
	                layer.alert("您上传的图片格式不对，请重新选择！");
	                return false;
	            }
	        },
	        onComplete: function(file, response) {
	        	if (file == null) {
	        		layer.alert('你没有上传任何文件或者选择了取消！');
					return;
				}
	            else {
	            	var filelist = eval(response);
	                img.src =filelist[0];
	                //后台修改当前用户的头像
	                $.ajax({
						url : "../systemUserBase/changeImg?image="+filelist[0],
						type : 'POST',
						data : "" ,
						dataType : 'json',
						success : function(data, status) {
							if(data==0){
								layer.alert("头像修改失败");
							}
							if(data==1){
								layer.alert("头像修改完成");
							}
						},
						error:function(){
							layer.alert("头像修改失败");
						}
	                })
	            }
	        }
	    });
	}

    
    
   	 	$.ajax({
				url : "../acmessage?_rnd="+ Math.random(10000000000),
				type : 'POST',
				data : "" ,
				dataType : 'json',
				success : function(data, status) {
					//alert(data);
					if (status == "success") {
						$("#unreadCount").html(data.unreadCount);
						$("#readCount").html(data.readCount);
						if(data.unreadCount>0){
							layer.tips('您有'+data.unreadCount+'条新消息', '#message', {
								  tips: [1, '#3595CC'],
								  time: 4000
								});
							$("#messnum").html(data.unreadCount);
						}
					}
				}
			});

    	 $.ajax({
				url : "../notice?_rnd="+ Math.random(10000000000),
				type : 'POST',
				data : "" ,
				dataType : 'json',
				success : function(data, status) {
					if (status == "success") {
						if(data.count>0){
							layer.open({
								  type: 1, //page层
				    			  area: ['50%', '50%'],
				    			  title: data.notices[0].title,
				    			  shade: 0.4, //遮罩透明度
				    			  moveType: 1, //拖拽风格，0是默认，1是传统拖动
				    			  shift: 1, //0-6的动画形式，-1不开启
				    			  closeBtn:1,
				    			  shadeClose: true,
				    			  skin: 'notic',
				    			  content: '<div  style="padding:50px;">'+data.notices[0].content+'</div>'
							});
							
							var contents="";
							for(var i=0;i<data.count;i++){
								var title=data.notices[i].title;
								var content=data.notices[i].content;
								title=title.replace(/\'/g,"").replace(/\"/g,"");
								content=content.replace(/\'/g,"").replace(/\"/g,"");
								
								contents+='<li>'
									+'<a href="javascript:void(0)" onclick="showNotic(\''+title+'\',\''+content+'\')">'
									+'<div class="small pull-right m-t-xs">'+data.notices[i].strCreateTime+'</div>'
									+'<h4>'+data.notices[i].title+'</h4> '+data.notices[i].content
									+' <div class="small text-muted m-t-xs">公告有效期： '+data.notices[i].strStartTime+' - '+data.notices[i].strEndTime+'</div>'
									+'</a>'
									+'</li>';
								
							}	
							$(".notices").html(contents);
// 							layer.tips('有'+data.count+'条执行中的公告', '#notic', {
// 								  tips: [1, '#3595CC'],
// 								  time: 4000
// 								});
// 							$("#noticnum").html(data.count);
						}
					}
				}
			});

    	 function showNotic(title,content){
    		 layer.open({
				  type: 1, //page层
	   			  area: ['50%', '50%'],
	   			  title: title,
	   			  shade: 0.4, //遮罩透明度
	   			  moveType: 1, //拖拽风格，0是默认，1是传统拖动
	   			  shift: 1, //0-6的动画形式，-1不开启
	   			  closeBtn:1,
	   			  shadeClose: true,
	   			  skin: 'notic',
	   			  content: '<div  style="padding:50px;">'+content+'</div>'
			});
     	}
    </script>
    
</body>

<script src="../js/ajaxupload.js"></script>
</html>
